<?php

/**
 * This is the model class for table "{{galeri}}".
 *
 * The followings are the available columns in table '{{galeri}}':
 * @property string $id
 * @property string $parent_id
 * @property integer $kat
 * @property string $nama
 * @property string $name_
 * @property string $isi
 * @property string $content
 * @property integer $status
 * @property string $tgl_buat
 * @property string $tgl_update
 * @property string $ip_update
 */
class Galeri extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Galeri the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{galeri}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('nama, isi, tgl_buat, tgl_update, ip_update', 'required'),
			array('kat, status', 'numerical', 'integerOnly'=>true),
			array('parent_id', 'length', 'max'=>11),
			array('nama, name_', 'length', 'max'=>250),
			array('ip_update', 'length', 'max'=>40),
			array('content', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, parent_id, kat, nama, name_, isi, content, status, tgl_buat, tgl_update, ip_update', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'parent_id' => 'Parent',
			'kat' => 'Kat',
			'nama' => 'Nama',
			'name_' => 'Name',
			'isi' => 'Isi',
			'content' => 'Content',
			'status' => 'Status',
			'tgl_buat' => 'Tgl Buat',
			'tgl_update' => 'Tgl Update',
			'ip_update' => 'Ip Update',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('parent_id',$this->parent_id,true);
		$criteria->compare('kat',$this->kat);
		$criteria->compare('nama',$this->nama,true);
		$criteria->compare('name_',$this->name_,true);
		$criteria->compare('isi',$this->isi,true);
		$criteria->compare('content',$this->content,true);
		$criteria->compare('status',$this->status);
		$criteria->compare('tgl_buat',$this->tgl_buat,true);
		$criteria->compare('tgl_update',$this->tgl_update,true);
		$criteria->compare('ip_update',$this->ip_update,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}